#ifndef _NODE_H_
#define _NODE_H_
template<class T>
class Node
{
public:
	T data;
	Node(const T& data, Node<T>* next = nullptr);
	void insertAfter(Node<T>* p);
	Node<T>* deleteAfter();
	Node<T>* nextNode();
	const Node<T>* nextNode() const;
private:
	Node<T>* next;
};

template <class T>
Node<T>::Node(const T& data, Node<T>* next):data(data),next(next){}

template <class T>
void Node<T>::insertAfter(Node<T>* p)
{
	p->next = this->next;
	this->next = p;

}

template <class T>
Node<T>* Node<T>::deleteAfter()
{
	Node<T>* tempPtr=next;
	if (tempPtr!=nullptr)
	{
		next = tempPtr->next;
	}
	return tempPtr;
	
}

template <class T>
Node<T>* Node<T>::nextNode()
{
	return next;
}

template <class T>
const Node<T>* Node<T>::nextNode() const
{
	return next;
}


#endif // !_NODE_H_

